package com.lj.exam.restclient;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.aliyuncs.exceptions.ClientException;
import com.lj.exam.model.SmsSendRequest;
import com.lj.exam.model.SmsSendResponse;
import com.lj.exam.service.SmsSendService;

@Controller
@RequestMapping("/SmsSendInfo")
public class SmsSendInfoRest {
	
    private final static Logger logger = LoggerFactory.getLogger(SmsSendInfoRest.class);
	
	@Autowired
	private SmsSendService smsSendService;
//	http://localhost:17077/SmsSendInfo/SmsSend
	@RequestMapping(value = "/smsSend",method = {RequestMethod.POST} )  
    @ResponseBody
    public  SmsSendResponse smsSend(@RequestBody SmsSendRequest req){
		logger.info("短信发送请求:");
		
		SmsSendResponse rsp = new SmsSendResponse();
		try {
			rsp = smsSendService.sendSms(req);
		} catch (ClientException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return rsp;
	}
	
	

	@RequestMapping("/smsSendTest")  
    @ResponseBody
    public String smsSendTest(@RequestBody SmsSendRequest param){
		logger.info("短信发送请求:"+param);
//		SmsSendResponse rsp = smsSendService.sendSms(param);
		return "ok";
	}
	
}
